import 'package:flutter/material.dart';
import '../res/ListData.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Namer App',
      theme: ThemeData(
        useMaterial3: true,
        colorScheme: ColorScheme.fromSeed(
            seedColor: const Color.fromARGB(255, 255, 3, 3)),
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text(
            '宝可梦大集结',
            style: TextStyle(
              color: Color.fromARGB(255, 255, 0, 0),
              fontSize: 24,
            ),
          ),
          backgroundColor: Color.fromARGB(255, 255, 255, 255),
        ),
        body: MyBody(),
      ),
    );
  }
}

// class MyBody extends StatelessWidget {
//   MyBody({super.key}) {
//     print(listData);
//   }

//   List<Widget> _initListData() {
//     return listData.map((value) {
//       return ListTile(
//         title: Text("${value["name"]}"),
//         subtitle: Text("${value["level"]}"),
//       );
//     }).toList();
//   }

//   @override
//   Widget build(BuildContext context) {
//     return ListView(
//       children: _initListData(),
//     );
//   }
// }

class MyBody extends StatelessWidget {
  MyBody({super.key});

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: listData.length,
      itemBuilder: (context, index) {
        return ListTile(
          title: Text(listData[index]["name"]),
          subtitle: Text(listData[index]["level"].toString()),
        );
      },
    );
  }
}
